package com.ysstech.finance.enums;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import com.ysstech.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 系统常量
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum FinanceAuxEnum implements BaseEnum<String> {
    STOCKCODE("STOCKCODE", "辅助项编码（股票代码）");
    private final String code;
    private final String desc;

    public static FinanceAuxEnum getEnum(String code) {
        return Arrays.stream(values()).filter(b -> Objects.equals(b.code, code)).findFirst().orElse(null);
    }

    public static String getEnumDesc(String code) {
        FinanceAuxEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }

    // 获取所有的值
    public static Map<String, String> getMapEnum() {
        Map<String, String> map = new HashMap<>();
        for (FinanceAuxEnum en : FinanceAuxEnum.values()) {
            map.put(en.getCode(), en.getDesc());
        }
        return map;
    }

}
